export {}

/*
interface 继承
- 使用 extends 实现接口继承，达到类型复用
*/

// 有两个接口，有相同的属性或者函数，如何提高代码复用？

// interface Point2D {
//   x: number
//   y: number
// }

// interface Point3D {
//   x: number
//   y: number
//   z: number
// }

// 通过接口集成完成代码复用

interface Point2D {
  x: number
  y: number
}

interface Point3D extends Point2D {
  z: number
}

// ------------------------

let p2d: Point2D = {
  x: 100,
  y: 100
}

let p3d: Point3D = {
  x: 100,
  y: 200,
  z: 300
}

console.log(p2d, p3d);

// ---------------------------
interface Animal {
  name: string
  age: number
  sex: string
}

interface Dog extends Animal {
  sing(): void
}

interface Cat extends Animal {
  eat(): void
}


let animal: Animal = {
  name: '',
  age: 10,
  sex: ''
}

let dog: Dog = {
  name: '',
  age: 19,
  sex: '',
  sing(){}
}

let cat: Cat = {
  name: '',
  age: 19,
  sex: '',
  eat(){}
}
